package com.lx.bigdata.api;

import com.lx.bigdata.manager.AIManager;
import com.lx.bigdata.model.Result;
import com.lx.bigdata.util.StringUtils;
import com.xl.bigdata.ai.sa.SentimentAnalysis;
import com.xl.bigdata.bean.SentimentAnalysisBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("barcode")
public class BarCodeController {

    private final static Logger logger = LoggerFactory.getLogger(BarCodeController.class);

    @Autowired
    private SentimentAnalysis sentimentAnalysis;

    @PostMapping(value = "/getBarCodeFromImage")
    public Result barcode(@RequestBody List<String> params) {
        logger.info("=================getBarCodeFromImage");
        if (StringUtils.isEmpty(params)) {
            logger.error("参数错误");
            return Result.error("参数错误");
        }

        List<Map<String, String>> resultList = new ArrayList<>();

        return Result.success(resultList);
    }

    @GetMapping(value = "/getAISenAnaV1")
    public Result barcode1(@RequestParam String text) {
        logger.info("=================getAISenAnaV1");

        SentimentAnalysisBean predict = sentimentAnalysis.predict(text);

        return Result.success(predict.toString());
    }
}
